//
// Created by cy on 22-5-4.
//

#ifndef CEC_VISION_TRANCE_H
#define CEC_VISION_TRANCE_H

#include "all.hpp"
#include "armor.hpp"

class TrancePorterPrivate;

enum class enuSpeedType {
    TYPE_VAL, TYPE_BUST
};

enum class enuCarType {
    TYPE_SOLDIER, TYPE_SENTRY
};

enum class enuOutPutType {
    TYPE_TUOLUO, TYPE_NORMAL
};

struct sutStm32Data {
    float pitch;
    float yaw;
    float shootV;
    enuArmorColor colorType;
    enuOutPutType predictType;
    bool predictFlag;
    bool isOk;
};

struct sutNucData {
    float pitch;
    float yaw;
    bool shoot;
    bool isOk;
};


class TrancePorter {

private:

    explicit TrancePorter(const std::string &port = "/dev/ttyUSB0",
                          LibSerial::BaudRate rate = LibSerial::BaudRate::BAUD_1152000, int timeout = 1);

    ~TrancePorter();

    TrancePorterPrivate *m_ptr;

public:
    static TrancePorter *
    getInstance(const std::string &port = "/dev/ttyUSB0", LibSerial::BaudRate rate = LibSerial::BaudRate::BAUD_1152000,
                int timeout = 1);

    void open();

    void close();

    sutStm32Data read();

    void write(const sutNucData &data);

    TrancePorter(const TrancePorter &) = delete;

    TrancePorter &operator=(const TrancePorter &) = delete;

    enuSpeedType SPEED_TYPE = TYPE_BUST;
};

//enuSpeedType TrancePorter::SPEED_TYPE = TYPE_BUST;

#endif //CEC_VISION_TRANCE_H
